home *** CD-ROM | disk | FTP | other *** search
-
-
-
- INFNAN Mathematical Library Procedures INFNAN
-
-
-
- NNAAMMEE
- infnan - signals invalid floating-point operations on a VAX
- (temporary)
-
- SSYYNNOOPPSSIISS
- ##iinncclluuddee <<mmaatthh..hh>>
-
- ddoouubbllee iinnffnnaann((iiaarrgg))
- iinntt iiaarrgg;;
-
- DDEESSCCRRIIPPTTIIOONN
- At some time in the future, some of the useful properties of
- the Infinities and _N_a_Ns in the IEEE standard 754 for Binary
- Floating-Point Arithmetic will be simulated in UNIX on the
- DEC VAX by using its Reserved Operands. Meanwhile, the
- Invalid, Overflow and Divide-by-Zero exceptions of the IEEE
- standard are being approximated on a VAX by calls to a pro-
- cedure _i_n_f_n_a_n in appropriate places in _l_i_b_m. When better
- exception-handling is implemented in UNIX, only _i_n_f_n_a_n among
- the codes in _l_i_b_m will have to be changed. And users of
- _l_i_b_m can design their own _i_n_f_n_a_n now to insulate themselves
- from future changes.
-
- Whenever an elementary function code in _l_i_b_m has to simulate
- one of the aforementioned IEEE exceptions, it calls
- infnan(iarg) with an appropriate value of _i_a_r_g. Then a
- reserved operand fault stops computation. But _i_n_f_n_a_n could
- be replaced by a function with the same name that returns
- some plausible value, assigns an apt value to the global
- variable _e_r_r_n_o, and allows computation to resume. Alterna-
- tively, the Reserved Operand Fault Handler could be changed
- to respond by returning that plausible value, etc. instead
- of aborting.
-
- In the table below, the first two columns show various
- exceptions signaled by the IEEE standard, and the default
- result it prescribes. The third column shows what value is
- given to _i_a_r_g by functions in _l_i_b_m when they invoke
- infnan(iarg) under analogous circumstances on a VAX.
- Currently _i_n_f_n_a_n stops computation under all those cir-
- cumstances. The last two columns offer an alternative; they
- suggest a setting for _e_r_r_n_o and a value for a revised _i_n_f_n_a_n
- to return. And a C program to implement that suggestion
- follows.
- IEEE IEEE
- Signal Default _i_a_r_g _e_r_r_n_o _i_n_f_n_a_n
- __________________________________________________
- Invalid _N_a_N EDOM EDOM 0
- Overflow +_Infinity ERANGE ERANGE HUGE
- Div-by-0 +_Infinity +_ERANGE ERANGE or EDOM +_HUGE
- (HUGE = 1.7e38 ... nearly 2.0**127)
-
-
-
-
- Sprite v1.0 May 27, 1986 1
-
-
-
-
-
-
- INFNAN Mathematical Library Procedures INFNAN
-
-
-
- ALTERNATIVE _i_n_f_n_a_n:
- ##iinncclluuddee <<mmaatthh..hh>>
- ##iinncclluuddee <<eerrrrnnoo..hh>>
- eexxtteerrnn iinntt eerrrrnnoo ;;
- ddoouubbllee iinnffnnaann((iiaarrgg))
- iinntt iiaarrgg ;;
- {{
- sswwiittcchh((iiaarrgg)) {{
- ccaassee EERRAANNGGEE:: eerrrrnnoo == EERRAANNGGEE;; rreettuurrnn((HHUUGGEE));;
- ccaassee --EERRAANNGGEE:: eerrrrnnoo == EEDDOOMM;; rreettuurrnn((--HHUUGGEE));;
- ddeeffaauulltt:: eerrrrnnoo == EEDDOOMM;; rreettuurrnn((00));;
- }}
- }}
-
- SSEEEE AALLSSOO
- math(3M), intro(2), signal(3).
-
- ERANGE and EDOM are defined in <errno.h>. See intro(2) for
- explanation of EDOM and ERANGE.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Sprite v1.0 May 27, 1986 2
-
-
-
-